<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p class="countime"></p>
    <button class="code">点击获取验证码</button>
</body>
<script>
    let code = document.querySelector('.code');
    let count = 60 
    let time = 60 
    let msg = '点击获取验证码'
    function countDown() {
        if(count == time){
            let timer = setInterval(()=>{
                if (count <= 0) {
                    code.innerHTML = '点击获取验证码';
                    count = time;
                    clearInterval(timer);
                    return;
                }
                count--;
                code.innerHTML = `${count}s`;
                console.log(count);
            },1000);
        }
    }

    code.onclick= () => {
        
        countDown()
    }
    
  
    




</script>
</html>